<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="csrf-token" content="{{ csrf_token() }}">
	<script src="/login/jquery-1.11.3.min.js"></script>
	 <link rel="stylesheet" href="/houtai/layui/css/layui.css">
	 <script src="/houtai/layui/layui.js"></script>
	<link rel="stylesheet" href="/shop/style/css/ch-ui.admin.css">
	<script type="text/javascript" src='/houtai/layui/jquery-3.2.1.js'></script>
	<link rel="stylesheet" href="/shop/style/font/css/font-awesome.min.css">
</head>
<body style="background:#F3F3F4;">
	<div class="login_box">
		<h1>Blog</h1>
		<h2>欢迎使用管理平台</h2>
		<div class="form">
			<!-- <p style="color:red">用户名错误</p> -->
			<form action="javascript:;" id="login_form" method="post">
				<ul>
					<li>
					<input type="text" name="username" id="username" class="text"/>
						<span><i class="fa fa-user"></i></span>
					</li>
					<li>
						<input type="password" name="password" id="password" class="text"/>
						<span><i class="fa fa-lock"></i></span>
					</li>
			
					<li>
						<input type="submit" value="立即登陆" />
					</li>
				</ul>
			</form>
		</div>
	</div>
</body>
</html>
<script type="text/javascript">
	$(function(){
		$.ajaxSetup({
			headers: {
				'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
			}
		});

	$("#login_form").submit(function(){
      var user = $("#username").val();
      var password = $("#password").val();
      layui.use('layer', function(){
      	$.ajax({
        url:"{{url('shop/action')}}",
        type: 'post',
        data: {user:user,password:password},
        // dataType: 'json',

        success:function(data){
          if(data['code'] == 1){
            {{--  跳转到首页  --}}
            window.location.href = "{{url('shop/home') }}";
          }else{
            layer.msg('账号或密码错误');
          }
        },
        error:function(){
          // alert("系统正忙");
        }
      })
      });
      
      

    })
  })
</script>